package com.gitee.ywj1352.user.service.impl;

import com.gitee.ywj1352.sharing.mapper.UserDao;
import com.gitee.ywj1352.sharing.po.User;
import com.gitee.ywj1352.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Random;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    UserDao userDao;

    @Override
    public Long addUser(User user) {
        User newUser = new User();
        Random random = new Random(121371237892424L);
        long idx = random.nextLong();
        newUser.setUserId(idx);
        newUser.setAge(23);
        newUser.setCreateTime(new Date());
        newUser.setGender(true);
        newUser.setPassword("2344"+idx);
        newUser.setPhone("18856173660");
        newUser.setUpdateTime(new Date());
        newUser.setRole(1);
        newUser.setUserName(user.getUserName());
        userDao.insert(newUser);
        return newUser.getUserId();
    }
}
